import com.alibaba.fastjson.JSONObject;
import com.gold.common.HttpUtils;
import com.gold.common.TokenUtil;
import com.gold.security.AuthSuccessHandler;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.junit.Test;
import sun.net.www.http.HttpClient;

/**
 * @author XiaoHao
 * @date 2022-04-19 09:43
 * 提交百度收录
 */
public class TimePost {
    @Test
    public void post(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("proxyIp","");
        jsonObject.put("proxyUserName","");
        jsonObject.put("proxyPassword","");
        jsonObject.put("deviceId","");
        jsonObject.put("deviceName","");
        //deviceType = 1 用mac登录 其他值忽略
        jsonObject.put("deviceType","1");
        JSONObject jsonObject1 = HttpUtils.doPost("http://124.221.64.146:8089/api/Login/GetQrCode", jsonObject.toJSONString());
        System.out.println(jsonObject1);
    }
    @Test
    public void post1(){
        JSONObject jsonObject1 = HttpUtils.doPost("http://124.221.64.146:8089/api/Login/CheckLogin/g7rswtWuiEhyKKvsn37t","" );
        Object data = jsonObject1.get("Data");
        if (data!=null){
            Object wxId = ((JSONObject) data).get("WxId");
            if (wxId!=null){
                System.out.println(wxId);
            }
        }


        System.out.println(jsonObject1);
    }
    @Test
    public void test1(){
        String tokenData = TokenUtil.getToken("","admin,");
        System.out.println(tokenData);
    }
    public static void main(String[] args) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost("http://data.zz.baidu.com/urls?site=45.77.159.87&token=7g6BWwoKQqtpjX7P");
        try {
            httpPost.setHeader("User-Agent","curl/7.12.1");
            httpPost.setHeader("Host","data.zz.baidu.com");
            httpPost.setHeader("Content-Type","text/plain");
            StringEntity stringEntity = new StringEntity("http://45.77.159.87/other/Chrome%E8%B0%B7%E6%AD%8C%E6%B5%8F%E8%A7%88%E5%99%A8%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7%E8%AF%A6%E8%A7%A3.html");
            httpPost.setEntity(stringEntity);
            CloseableHttpResponse response = httpClient.execute(httpPost);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            System.out.println(statusCode);
            System.out.println(response.getEntity().toString());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
